package com.example.shiwuyouproject.ui.modelview

import androidx.lifecycle.MutableLiveData
import com.example.shiwuyouproject.base.BaseViewModel
import com.example.shiwuyouproject.ui.fragment.my.bean.GetUserCenterBean
import com.example.shiwuyouproject.ui.my.bean.PersonalInformationBean

class MyViewModel:BaseViewModel() {
    private val loginRepository by lazy { RetrofitClient.getApiService() }
    val getUserCenterState = MutableLiveData<GetUserCenterBean>()
    /**
     * 个人中心用户信心
     */
    fun getUserCenter(){
        launch(
            block = {
                val codeStatus = loginRepository.getUserCenter()
                getUserCenterState.value=codeStatus.result()
            },
            error = {
                    messageStatus.value="返回异常:"+it.message
            },
            cancel = {
                messageStatus.value="返回异常:"+it.message
            },
            showErrorToast = false
        )
    }

    val getGenRenStatus = MutableLiveData<PersonalInformationBean>()
    fun getRealNameAuthenticationData(){
        launch(
            block = {
                val codeStatus = loginRepository.userUpdate()
                getGenRenStatus.value=codeStatus.result()
            },
            error = {
            },
            cancel = {

            },
            showErrorToast = false
        )
    }

}